package com.alibaba.cloud.client8081.stream;

import com.alibaba.cloud.client8081.config.ClientSink;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;

/**
 * created by wuquan at 05/07/2021
 * ^_^ ^_^
 * 消费者监听
 */
@EnableBinding({Sink.class, ClientSink.class})

public class ConsumerListener {

    @StreamListener(Sink.INPUT)
    public void receive(@Payload JSONObject deploy, @Header("token") String token, @Header("name") JSONObject name) {

        System.out.println(deploy.toJSONString() + "===============" + token + "***" + name.toJSONString());
    }

    @StreamListener(ClientSink.INPUT)
    public void receive1(@Payload JSONObject deploy, @Header("token") String token, @Header("name") JSONObject name) {

        System.out.println(deploy.toJSONString() + "===============" + token + "***" + name.toJSONString());
    }



}
